addrService.$inject = ['$rootScope','$http'];

function addrService($rootScope, $http) {
    var appContext = require('../../../config/app.context');
    var urlBase = appContext.path + '/api/customers';
    var _addrService = {};

    _addrService.getAddressListByCustomerId = function(cId) {
        return $http.get(urlBase + '/findAddressList/' + cId);
    }

    _addrService.addAddress = function(addr) {
        // console.log($rootScope.globalData.loginedCustomer);
        return $http.put(urlBase + '/addAddress', addr);
    }

    _addrService.removeAddress = function(cId, addrId) {
        return $http.delete(urlBase + '/' + cId + '/deleteAddress/' + addrId);
    }

    return _addrService;
}

module.exports = addrService;